import { createBrowserRouter } from "react-router-dom";
import { lazy } from "react";
import Home from "../pages/Home";
// import DrawingBoardPage from "../pages/MyFiles/DrawingBoardPage";
const Layout = lazy(() => import("../layout"));
const Notes = lazy(() => import("../pages/Notes"));
const MyFiles = lazy(() => import("../pages/MyFiles"));

const FolderPage = lazy(() => import("../pages/MyFiles/FolderPage"));
const MdPage = lazy(() => import("../pages/MyFiles/MdPage"));
const ExcelPage = lazy(() => import("../pages/MyFiles/ExcelPage"));
const DrawingBoardPage = lazy(() => import("../pages/MyFiles/DrawingBoardPage"));
const Collection = lazy(() => import("../pages/Collection"));
const Login = lazy(() => import("../pages/Login"));
const Warehouse = lazy(() => import("../pages/Warehouse"));
export type Route = {
    path: string;
    element: React.ReactNode;
    children?: Route[];
    name?: string;
}

const routers = createBrowserRouter([
    {
        path: "/",
        element: <Layout />,
        children: [
            {
                path: '/start',
                name: '开始',
                element: <Home />,
            } as Route,
            {
                path: '/notes',
                name: '小记',
                element: <Notes />,
            } as Route,
            {
                path: '/collection',
                name: '收藏',
                element: <Collection />,
            } as Route,
            {
                path: '/warehouse',
                name: '文档库',
                element: <Warehouse/>,
            } as Route,
            {
                path: '/myfile',
                name: '我的文件',
                element: <MyFiles />,
                children: [
                    {
                        path: '/myfile/folder/:key',
                        name: '文件夹',
                        element: <FolderPage />,
                    } as Route,
                    {
                        path: '/myfile/md/:key',
                        name: 'Markdown',
                        element: <MdPage />,
                    } as Route,
                    {
                        path: '/myfile/excel/:key',
                        name: 'Excel',
                        element: <ExcelPage />,
                    },
                    {
                        path: '/myfile/drawingBoard/:key',
                        name: 'DrawingBoard',
                        element: <DrawingBoardPage />,
                    },
                ]
            } as Route,
            {
                path: '*',
                element: <>404</>
            } as Route
        ]
    },
    {
        path: "/login",
        element: <Login />,
    },
    // {
    //     path: '/myfile',
    //     name: '我的文件',
    //     element: <MyFiles />,
    //     children: [
    //         {
    //             path: '/myfile/folder/:key',
    //             name: '文件夹',
    //             element: <FolderPage />,
    //         } as Route,
    //         {
    //             path: '/myfile/md/:key',
    //             name: 'Markdown',
    //             element: <MdPage />,
    //         } as Route,
    //         {
    //             path: '/myfile/excel/:key',
    //             name: 'Excel',
    //             element: <ExcelPage />,
    //         },
    //         {
    //             path: '/myfile/drawingBoard/:key',
    //             name: 'DrawingBoard',
    //             element: <DrawingBoardPage />,
    //         },
    //     ]
    // } as Route,
]);

export default routers;